package com.hutao.manage.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.hutao.manage.datasource.TargetDataSource;
import com.hutao.manage.mapper.HospNoteBasicJsonMapper;
import com.hutao.manage.service.HospNoteBasicJsonService;
import com.hutao.manage.util.StringUtil;
@Service
public class HospNoteBasicJsonServiceImpl implements HospNoteBasicJsonService {

	@Autowired
	private HospNoteBasicJsonMapper hospNoteBasicJsonMapper;
	
	
	@TargetDataSource(name="ds1")
	@Transactional(propagation=Propagation.REQUIRED)
	@Override
	public int addHospNoteBasicJson(String hospNoteBasicJson) {
	
		return hospNoteBasicJsonMapper.insert(hospNoteBasicJson);
	}


	@TargetDataSource(name="ds1")
	@Transactional(readOnly=true)
	@Override
	public String getHospBasicJsonByFirstGuid(String firstGuid) {
		String hospNoteJson=null;
		List<String> hospNoteJsonList=hospNoteBasicJsonMapper.getHospBasicJsonByFirstGuid(firstGuid);
		if(hospNoteJsonList!=null && hospNoteJsonList.size()>0){
			hospNoteJson=hospNoteJsonList.get(0);
		}
		return hospNoteJson;
	}


	@TargetDataSource(name="ds1")
	@Transactional(propagation=Propagation.REQUIRED)
	@Override
	public int updateHospBasicJsonByFirstGuid(String firstGuid,String hosBasicJson) {
		//删除json数据
		hospNoteBasicJsonMapper.deleteHospBasicJsonByFirstGuid(StringUtil.handleJsonParam(firstGuid));
		System.err.println(hosBasicJson);
		hospNoteBasicJsonMapper.insert(hosBasicJson);
		return 0;
	}


	@TargetDataSource(name="ds1")
	@Transactional(readOnly=true)
	@Override
	public List<Map<String, Object>> ajax_getMainDiagnoseDiseaseTop12(Map<String, Object> params) {
		List<Map<String, Object>> list = hospNoteBasicJsonMapper.ajax_getMainDiagnoseDiseaseTop12(params);
		return list;
	}


	@TargetDataSource(name = "ds1")
	@Transactional(readOnly=true)
	@Override
	public List<Map<String, Object>> ajax_getSecondDiagnoseDiseaseTop12(Map<String, Object> params) {
		List<Map<String, Object>> list = hospNoteBasicJsonMapper.ajax_getSecondDiagnoseDiseaseTop12(params);
		return list;
	}


	@TargetDataSource(name = "ds1")
	@Transactional(readOnly=true)
	@Override
	public List<Map<String, Object>> ajax_getMainOperationTop(Map<String, Object> params) {
		List<Map<String, Object>> list = hospNoteBasicJsonMapper.ajax_getMainOperationTop(params);
		return list;
	}

	
	
	
	
	
	
	
	
}










